package com.chenx.gameview;

import com.chenx.gameinterface.GameImage;

import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;

public class BeiJingImage implements GameImage
{
	/*
	 * 负责背景图片处理
	 */
	private int display_w, display_h;
	private int height = 0;
	private Bitmap bg;
	private Bitmap newbg = null;

	public BeiJingImage(Bitmap bg, int display_w, int display_h)
	{
		this.display_w = display_w;
		this.display_h = display_h;
		this.bg = bg;
		newbg = Bitmap.createBitmap(display_w, display_h, Config.ARGB_8888);
	}

	@Override
	public Bitmap getBitmap()
	{
		Paint p = new Paint();
		Canvas canvas = new Canvas(newbg);
		canvas.drawBitmap(bg, new Rect(0, 0, bg.getWidth(), bg.getHeight()),
				new Rect(0, height, display_w, display_h + height), p);

		canvas.drawBitmap(bg, new Rect(0, 0, bg.getWidth(), bg.getHeight()),
				new Rect(0, -display_h + height, display_w, height), p);
		

		height++;
		if (height == display_h)
		{
			height = 0;
		}
		return newbg;
	}

	@Override
	public int getX()
	{
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int getY()
	{
		// TODO Auto-generated method stub
		return 0;
	}

}
